home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
UPC12BS2.ZIP
/
RNEWS
/
RNEWS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-27
|
50KB
|
1,415 lines
/*--------------------------------------------------------------------*/
/* r n e w s . c */
/* */
/* Receive incoming news into the news directory. */
/* */
/* Written by Mike Lipsie; modified for UUPC/extended 1.11s by */
/* Andrew H., Derbyshire. */
/* */
/* Changes and Compilation Copyright (c) 1992 by Andrew H. */
/* Derbyshire. All rights reserved except as granted by the */
/* general UUPC/extended license. */
/* */
/* This package has been substantially modified. It will now */
/* copy compressed articles (assumed batches but they could be */
/* single articles) to the CMPRSSED directory and it will */
/* unbatch (if necessary) and deliver articles to their */
/* appropriate newsgroup directories. At the end, if the file */
/* was compressed it will invoke a batch file which will */
/* uncompress the file and then feed it back to rnews. */
/* */
/* Appropriate is defined as */
/* */
/* (a) the newsgroup is in the active file and */
/* (b) the directory name is the group name with all */
/* the"."s replaced with "/"s and all of that under the */
/* news directory. */
/* */
/* Names are insured to be valid by ImportNewsGroup, which maps */
/* invalid characters and truncates names as required. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: rnews.c 1.17 1993/09/27 04:04:06 ahd Exp $
*
* $Log: rnews.c $
* Revision 1.17 1993/09/27 04:04:06 ahd
* Reduce buffer sizes to avoid 16 bit stack over flows
*
* Revision 1.16 1993/09/24 03:43:27 ahd
* Double buffers to avoid crashes during Disney Stock Flame War
*
* Revision 1.15 1993/09/21 01:42:13 ahd
* Suppress changes to body of delivered news
*
* Revision 1.14 1993/09/20 04:41:54 ahd
* OS/2 2.x support
*
* Revision 1.13 1993/07/31 16:26:01 ahd
* Changes in support of Robert Denny's Windows support
*
* Revision 1.12 1993/07/22 23:19:50 ahd
* First pass for Robert Denny's Windows 3.x support changes
*
* Revision 1.11 1993/05/03 02:41:57 ahd
* Correct name of file to set into binary mode
*
* Revision 1.10 1993/04/19 13:16:20 ahd
* Binary mode for snews
*
* Revision 1.9 1993/04/17 13:40:39 ahd
* fix compile errors for snews fix
*
* Revision 1.8 1993/04/17 13:23:37 ahd
* make snews option more compatible with snews (which is brain dead)
*
* Revision 1.7 1993/04/16 12:55:36 dmwatt
* Bounds check group lengths
*
* Revision 1.5 1993/04/11 00:33:54 ahd
* Global edits for year, TEXT, etc.
*
* Revision 1.4 1993/03/24 01:57:30 ahd
* Corrections for short articles
* Corrections for articles claimed to be zero length
* Resync gracefully after incorrect length descriptor
*
* Revision 1.3 1993/03/06 23:04:54 ahd
* Do not delete open files
*
* Revision 1.2 1992/11/22 21:14:21 ahd
* Reformat selected sections of code
* Check for premature end of articles in batched news
*
*/
static const char rcsid[] =
"$Id: rnews.c 1.17 1993/09/27 04:04:06 ahd Exp $";
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <fcntl.h>
#include <io.h>
#include <process.h>
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "active.h"
#include "getopt.h"
#include "getseq.h"
#include "history.h"
#include "hlib.h"
#include "import.h"
#include "importng.h"
#include "logger.h"
#include "timestmp.h"
#include "execute.h"
/*--------------------------------------------------------------------*/
/* Global defines */
/*--------------------------------------------------------------------*/
#define UNCOMPRESS "uncompre"
#ifdef BIT32ENV
#define DISNEY (BUFSIZ*2)
#else
#define DISNEY (BUFSIZ*4/3)
#endif
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
currentfile();
extern struct grp *group_list; /* List of all groups */
FILE *hfile = NULL; /* History file */
char history_date[12]; /* dd/mm/yyyy + null + 1 for no good reason */
/*--------------------------------------------------------------------*/
/* Functions in this file */
/*--------------------------------------------------------------------*/
static boolean deliver_article(char *art_fname);
/* Distribute the article to the
proper newsgroups */
static void copy_file(FILE *f,
char *group,
char *xref); /* Copy file (f) to newsgroup */
static struct grp *find_newsgroup(const char *grp);
/* Get the grp struct for the newsgroup */
static void get_snum(const char *group, char *snum);
/* Get (and format) the next article
number in group */
static void fixEOF( char *buf, int bytes );
static int Single( char *filename , FILE *stream );
static int Compressed( char *filename , FILE *in_stream );
static int Batched( char *filename, FILE *stream);
static void xmit_news( char *sysname, FILE *in_stream );
static int copy_snews( char *filename, FILE *stream );
/*--------------------------------------------------------------------*/
/* m a i n */
/* */
/* Main program */
/* */
/* Exit conditions */
/* */
/* 0 - Success */
/* 1 - System configuration failed */
/* 2 - Unable to open working file */
/* 4 - out of memory */
/* 5 - Unable to create history dbm file */
/* 6 - Problem decompressing news batch */
/* 7 - Unable to create cmprssed directory */
/*--------------------------------------------------------------------*/
void main( int argc, char **argv)
{